/**
 * 二维数组，将给定的块的边界画出来。
 */
#include <bits/stdc++.h>
using namespace std;
int const DR[] = {-1,1,0,0};
int const DC[] = {0,0,-1,1};
int n,m;
char A[510][510];
int B[510][510] = {0};
void dfs(int r,int c){
    for(int i=0;i<4;++i){
        int dr = r + DR[i];
        int dc = c + DC[i];
        if(0<=dr&&dr<n&&0<=dc&&dc<m&&A[dr][dc]=='.'&&B[dr][dc]==0){
            B[dr][dc] = 1;
            dfs(dr,dc);
        }
    }
}
bool isOK(int r,int c){
    for(int i=0;i<4;++i){
        int dr = r + DR[i];
        int dc = c + DC[i];
        if(0<=dr&&dr<n&&0<=dc&&dc<m&&A[dr][dc]=='#'){
            return true;
        }
    }
    return false;
}
int main(){
    //freopen("1.txt","r",stdin);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)scanf("%s",A[i]);
    B[0][0] = 1;
    dfs(0, 0);
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            if(1==B[i][j]&&isOK(i,j))A[i][j]='*';
        }
        puts(A[i]);
    }
    return 0;
}
